wave2 <- read.csv("full.csv")

wave2$anger <- as.numeric(wave2$Q3 != "")
wave2$anxiety <- as.numeric(wave2$Q4 != "")

wave2$ideology <- as.numeric(wave2$Q51)
wave2$income <- as.numeric(wave2$Q46)
wave2$zipcode <- as.numeric(paste(wave2$Q49))

wave2$local_white <- as.numeric(wave2$Q7_1)
wave2$local_black <- as.numeric(wave2$Q7_2)
wave2$local_hispanic <- as.numeric(wave2$Q7_3)
wave2$local_asian <- as.numeric(wave2$Q7_4)
wave2$local_immigrant <- as.numeric(wave2$Q8_1)
wave2$local_muslim <- as.numeric(wave2$Q52)
wave2$local_christian <- as.numeric(wave2$Q9)
wave2$local_college <- as.numeric(wave2$Q10)

wave2$white <- 0
wave2$white[grep("1", paste(wave2$Q24))] <- 1

wave2$national_white <- as.numeric(wave2$Q16_1)
wave2$national_black <- as.numeric(wave2$Q16_2)
wave2$national_hispanic <- as.numeric(wave2$Q16_3)
wave2$national_asian <- as.numeric(wave2$Q16_4)
wave2$national_immigrant <- as.numeric(wave2$Q17_1)
wave2$national_muslim <- as.numeric(wave2$Q53)
wave2$national_christian <- as.numeric(wave2$Q18_2)
wave2$national_college <- as.numeric(wave2$Q19_1)

wave2$whiteft <- wave2$Q6.1_1
wave2$blackft <- wave2$Q6.1_2
wave2$hispft <- wave2$Q6.1_3
wave2$asianft <- wave2$Q6.1_4

# Q20
feelhateful <- 8-as.numeric(wave2$Q20_1)
feelhopeful <- 8-as.numeric(wave2$Q20_2)
feelenthusiastic<- 8-as.numeric(wave2$Q20_3)
feelangry<- 8-as.numeric(wave2$Q20_4)
feelresentful<- 8-as.numeric(wave2$Q20_5)
feelafraid<- 8-as.numeric(wave2$Q20_6)
feelproud<- 8-as.numeric(wave2$Q20_7)
feelbitter<- 8-as.numeric(wave2$Q20_8)
feelworried<- 8-as.numeric(wave2$Q20_9)
feelanxious <- 8-as.numeric(wave2$Q20_10)

#HATEFUL ANGRY RESENTFUL BITTER Q20 alpha reliability 0.93
wave2$anger.av <- (feelangry+feelresentful+feelhateful+feelbitter)/4

#WORRIED ANXIOUS AFRAID Q20 alpha reliability 0.89
wave2$anxiety.av <- (feelanxious+feelworried+feelafraid)/3

